function [] = calcDistanceMatrix(inputCoordsFile, outputFile, distanceMeasure)
	
	% Add paths
	addpath('../code/general_funcs');
	
	% Read coordinates
	[coords, geoLabels] = makeArrayFromCSV(inputCoordsFile, 1, {'char', 'double', 'double'});
	geoLabels = geoLabels{1};
	
	% Determine distance measure
	distanceCode = 0;
	if strcmp(distanceMeasure, 'euclidean')
		distanceCode = 1;
	else if strcmp(distanceMeasure, 'haversine')
		distanceCode = 2;
		radius=6371;
	end
	end
	
	% Initialize output structure
	NumPoints = size(coords, 1);
	W = zeros(NumPoints, NumPoints);
	
	% Loop
	for p1 = 2:NumPoints
	
		coords1 = coords(p1,:);
		for p2 = 1:p1-1
			coords2 = coords(p2,:);
			
			if distanceCode == 1 % euclidean distance
				mydist = sqrt(sum((coords1 - coords2).^2));
			else if distanceCode == 2 % haversine distance
				lat1 = coords1(1);
				lng1 = coords1(2);
				lat2 = coords2(1);
				lng2 = coords2(2);				
				lat1  =lat1*pi/180;
    			lng1 =lng1*pi/180;
    			lat2  =lat2*pi/180;
    			lng2 =lng2*pi/180;
    			dlat  = lat2-lat1;
    			dlng = lng2-lng1;
    			tmp = sin(dlat/2)^2 + cos(lat1)*cos(lat2)*sin(dlng/2)^2;
    			mydist = 2*radius*asin(sqrt(tmp));
			end
			end
			W(p1, p2) = mydist;
			W(p2, p1) = mydist;
		end
	end
	
	weightMatrixName = 'GeoDistance';
	save(outputFile, 'W', 'geoLabels', 'weightMatrixName', '-v7.3');
end
